package dao

import (
	"fmt"
	"gin/CloudRestaurant/model"
	"gin/CloudRestaurant/tool"
)

type StudentDao struct {
	*tool.Orm
}

// 插入一条学生信息
func (md *StudentDao) InsertOneStudent(stu *model.Student) int64 {
	result, err := md.InsertOne(&stu)
	if err != nil {
		fmt.Println(err.Error())
	}
	return result
}

// 根据学号查询一条数据
func (md *StudentDao) FindByNumber(StudentNumber int64) *model.Student {
	var stu model.Student
	if _, err := md.Where("student_number = ?", StudentNumber).Get(&stu); err != nil {
		return &stu
	}
	return nil
}

